package ru.spb.osll.myfit.client.widget;

import ca.nanometrics.gflot.client.PlotModel;
import ca.nanometrics.gflot.client.PlotSelectionArea;
import ca.nanometrics.gflot.client.SimplePlot;
import ca.nanometrics.gflot.client.options.PlotOptions;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;

public class PassiveSelectionPlot extends Composite {
  private FlowPanel m_overlay;
  private SimplePlot m_plot;

  public PassiveSelectionPlot(PlotModel plotModel, PlotOptions overviewPlotOptions) {
    m_plot = new SimplePlot(plotModel, overviewPlotOptions);

    m_overlay = new FlowPanel();
    m_overlay.setStyleName(IStyleConstants.EMPTY_DIV_OVERLAY_FOR_CHART_PREVIEW);
    m_overlay.setWidth(Integer.toString(m_plot.getWidth()));

    FlowPanel flowPanel = new FlowPanel();
    flowPanel.setStyleName(IStyleConstants.CONTAINER_FOR_CHART_PREVIEW);
    flowPanel.add(m_plot);
    flowPanel.add(m_overlay);

    initWidget(flowPanel);
  }

  public void setHeight(int height) {
    m_plot.setHeight(height);
    m_overlay.setHeight(Integer.toString(height));
  }

  public void setWidth(int width) {
    m_plot.setWidth(width);
    m_overlay.setWidth(Integer.toString(width));
  }

  public int getHeight() {
    return m_plot.getHeight();
  }

  public void setSelection(PlotSelectionArea area) {
    m_plot.setSelection(area);
  }

  public void clearSelection() {
    m_plot.clearSelection();
  }

  public FlowPanel getOverlay() {
    return m_overlay;
  }
}
